package com.fun.widget.tag;

import android.graphics.Color;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;

import com.fun.widget.tag.bean.TagBean;
import com.fun.widget.tag.core.TagStyleBuilder;

import java.util.ArrayList;
import java.util.List;

public class MainActivity extends AppCompatActivity {

    private List<TagBean> tag2Beans;
    private TagsView<TagBean> tagsView1;
    private TagsView<TagBean> tagsView2;
    private TagsView<TagBean> tagsView3;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        this.initTestData();
        this.tagsView1 = findViewById(R.id.tags_layout_1);
        this.tagsView2 = findViewById(R.id.tags_layout_2);
        this.tagsView3 = findViewById(R.id.tags_layout_3);

        this.tagsView1.setStyleBuilder(tag2Beans.get(2).getStyleBuilder());
        this.tagsView1.setTags(tag2Beans);

        this.tagsView2.setStyleBuilder(tag2Beans.get(3).getStyleBuilder());
        this.tagsView2.setTags(tag2Beans);

        this.tagsView3.setTags(tag2Beans);
    }

    private void initTestData() {
        this.tag2Beans = new ArrayList<>();
        TagStyleBuilder styleBuilder = new TagStyleBuilder();
        styleBuilder.reset(this);
        styleBuilder.setFillLine(true);

        //
        TagBean tag2Bean1 = new TagBean();
        tag2Bean1.setText("1111111");
        tag2Bean1.setStyleBuilder(styleBuilder.clone());

        TagBean tag2Bean2 = new TagBean();
        tag2Bean2.setText("2222222");
        TagStyleBuilder builder2 = styleBuilder.clone();
        builder2.setTextColor(Color.parseColor("#41C856"));
        builder2.setBorderColor(Color.parseColor("#41C856"));
        builder2.setBackgroundColor(Color.parseColor("#EEEE00"));
        builder2.setFillLine(false);
        tag2Bean2.setStyleBuilder(builder2);

        TagBean tag2Bean3 = new TagBean();
        tag2Bean3.setText("33333333");
        TagStyleBuilder builder3 = styleBuilder.clone();
        builder3.setTextColor(Color.parseColor("#FF7F00"));
        builder3.setBorderColor(Color.parseColor("#FF7F00"));
        builder3.setBackgroundColor(Color.parseColor("#FFFFFF"));
        builder3.setFillLine(true);
        tag2Bean3.setStyleBuilder(builder3);


        TagBean tag2Bean4 = new TagBean();
        tag2Bean4.setText("4444444444444");
        TagStyleBuilder builder4 = styleBuilder.clone();
        builder4.setTextColor(Color.parseColor("#CD00CD"));
        builder4.setBorderColor(Color.parseColor("#CD00CD"));
        builder4.setBackgroundColor(Color.parseColor("#DEB887"));
        builder4.setFillLine(false);
        tag2Bean4.setStyleBuilder(builder4);

        TagBean tag2Bean5 = new TagBean();
        tag2Bean5.setText("55555555555");
        TagStyleBuilder builder5 = styleBuilder.clone();
        builder5.setTextColor(Color.parseColor("#C0FF3E"));
        builder5.setBorderColor(Color.parseColor("#C0FF3E"));
        builder5.setBackgroundColor(Color.parseColor("#778899"));
        builder5.setFillLine(true);
        tag2Bean5.setStyleBuilder(builder5);

        TagBean tag2Bean6 = new TagBean();
        tag2Bean6.setText("66666666");
        TagStyleBuilder builder6 = styleBuilder.clone();
        builder6.setTextColor(Color.parseColor("#8B5A2B"));
        builder6.setBorderColor(Color.parseColor("#8B5A2B"));
        builder6.setBackgroundColor(Color.parseColor("#FFFFFF"));
        builder6.setFillLine(false);
        tag2Bean6.setStyleBuilder(builder6);

        TagBean tag2Bean7 = new TagBean();
        tag2Bean7.setText("77777777777");
        TagStyleBuilder builder7 = styleBuilder.clone();
        builder7.setTextColor(Color.parseColor("#0000EE"));
        builder7.setBorderColor(Color.parseColor("#0000EE"));
        builder7.setBackgroundColor(Color.parseColor("#FFFFFF"));
        builder7.setFillLine(true);
        tag2Bean7.setStyleBuilder(builder7);

        this.tag2Beans.add(tag2Bean1);
        this.tag2Beans.add(tag2Bean2);
        this.tag2Beans.add(tag2Bean3);
        this.tag2Beans.add(tag2Bean4);
        this.tag2Beans.add(tag2Bean5);
        this.tag2Beans.add(tag2Bean6);
        this.tag2Beans.add(tag2Bean7);
    }

}
